package com.dom.config;

import org.springframework.cache.ehcache.EhCacheManagerFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.core.io.ClassPathResource;

/**
 * @Description eh缓存配置类
 * @Author xllei
 * @Date 2018/11/18 11:08 AM
 * @Version 1.0
 **/
//@Configuration
//@EnableCaching
public class EhCacheConfig {
//    /**
//     * EhCache的配置
//     */
//    @Bean
//    public EhCacheCacheManager cacheManager(EhCacheManagerFactoryBean cacheManager) {
//        return new EhCacheCacheManager(cacheManager.getObject());
//    }

    /**
     * EhCache的配置
     */
    @Bean
    public EhCacheManagerFactoryBean ehcache() {
        EhCacheManagerFactoryBean ehCacheManagerFactoryBean = new EhCacheManagerFactoryBean();
        ehCacheManagerFactoryBean.setConfigLocation(new ClassPathResource("ehcache.xml"));
        ehCacheManagerFactoryBean.setShared(true);
        return ehCacheManagerFactoryBean;
    }
}
